/*!
 * \file dcom_core.c
 *
 * \brief dcom数据包解析
 *
 * All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.\n
 *
 * \version 2.0
 * \author geyh
 * \date 2015/11/11
 *
 */
#include <stdio.h>

#include "conntrack.h"
#include "module.h"
#include "frlog.h"

#include "config.h"
#include "dcom_core.h"

void *g_p_apm_context=NULL;

#ifdef  __cplusplus
extern "C"
{
#endif

/*!
 * dcom 模块加载
 *
 * \p_context				(void *		框架的上下文引用)
 * \p_module_params			(const char*	模块入力参数)
 * \p_module_cfg			(L7_module_config *		协议加载模块 配置文件)
 *
 * \return			FR_SUCC:	成功\n
 * 					FR_FAIL:	失败\n
 *
 */
int module_init(void *p_context, const char* p_module_params, L7_module_config *p_module_cfg)
{
	int i_ret_fun = FR_SUCC;

	if(p_context == NULL || p_module_params == NULL || p_module_cfg == NULL)
		return FR_FAIL;

	if( fr_slab_init( (Frmem_env *)(((ApmContext *)p_context)->p_st_mem_env), MODULE_NAME) == NULL )
	{
		return FR_FAIL;
	}

    frlog_set_hd(((ApmContext *)p_context)->p_st_log_category);
	p_module_cfg->p_l4_proto = MODULE_L4PROTO;
	p_module_cfg->i_l7_proto = MODULE_L7PROTO;
	p_module_cfg->p_module_name = MODULE_NAME;
	p_module_cfg->p_version = MODULE_VERSION " " MODULE_TIME;
	p_module_cfg->l7_detect = dcom_detect;
	p_module_cfg->l7_analysis = dcom_analysis;
	p_module_cfg->session_destory = dcom_session_destroy;

	return FR_SUCC;
}

/*******************************************************************************
*  FUNC     :  dcom销毁
*  ARGS     :  void
*  RTN      :
*  NOTE     :
*******************************************************************************/
void module_exit(void)
{
	frdbg("dcom_destroy\n");
	fr_slab_destroy();

	return;
}

#ifdef  __cplusplus
}
#endif
